package org.jeecg.modules.zcgl.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.base.controller.BaseController;
import org.jeecg.common.util.ImportExcelUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysDictItem;
import org.jeecg.modules.system.service.ISysDictItemService;
import org.jeecg.modules.zcgl.service.*;
import org.jeecg.modules.zcgl.vo.AssetLedgerVo;
import org.jeecg.modules.zcgl.vo.CollectionInformationVo;
import org.jeecg.modules.zcgl.vo.statistical.*;
import org.jeecg.modules.zcgl.vo.statistical.sum.ContractParameterSumVo;
import org.jeecg.modules.zcgl.vo.statistical.AssetsParameterStatisticalVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Api(tags = "统计报表")
@RestController
@RequestMapping("/zcgl/statisticalReport")
@Slf4j
public class StatisticalReportController extends BaseController {


    @Autowired
    private IAssetInfoService assetInfoService;
    @Autowired
    private ISysDictItemService sysDictItemService;
    @Autowired
    private IReceivablesInfoService receivablesInfoService;
    @Autowired
    private ILeaseContractInfoService contractInfoService;
    @Autowired
    private ICustomerInfoService customerInfoService;
    @Autowired
    private IOrderPrestoreService orderPrestoreService;
    @Autowired
    private IRepairInfoService repairInfoService;
    @Autowired
    private IPublicAccountTransactionInquiryDetailsService publicAccountTransactionInquiryDetailsService;
    @Autowired
    private IPayablesInfoService payablesInfoService;

    /**
     * 资产台账列表查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "资产台账-分页列表查询")
    @ApiOperation(value = "资产台账-分页列表查询", notes = "资产台账-分页列表查询")
    @GetMapping(value = "/assetLedger")
    public Result<IPage<AssetLedgerVo>> queryAssetLedgerPageList(AssetLedgerVo vo,
                                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                 HttpServletRequest req) {
//        QueryWrapper<AssetLedgerVo> queryWrapper = QueryGenerator.initQueryWrapper(vo, req.getParameterMap());
        vo.setSelections(null);
        QueryWrapper<AssetLedgerVo> queryWrapper = new QueryWrapper<>(vo);
        Page<AssetLedgerVo> page = new Page<>(pageNo, pageSize);
        IPage<AssetLedgerVo> pageList = assetInfoService.queryAssetLedgerVoList(page, queryWrapper);
        return Result.ok(pageList);
    }


    /**
     * 资产台账导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "资产台账-导出excel")
    @RequestMapping(value = "/assetLedger/exportXls")
    public ModelAndView exportXls(HttpServletRequest req, AssetLedgerVo vo) {
        List<AssetLedgerVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<AssetLedgerVo> queryWrapper = new QueryWrapper<>();
            AssetLedgerVo vo1 = new AssetLedgerVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList = assetInfoService.queryAssetLedgerVoList(queryWrapper);
        } else {
            QueryWrapper<AssetLedgerVo> queryWrapper = new QueryWrapper<>(vo);
            pageList = assetInfoService.queryAssetLedgerVoList(queryWrapper);
        }

        return super.exportXls("资产台账信息", pageList, AssetLedgerVo.class, true);
    }

    /**
     * 资产台账下载excel模版
     *
     * @param request
     * @param title
     */
    @RequestMapping(value = "/assetLedger/exportXlsTemplate")
    public ModelAndView exportAssetLedgerXlsTemplate(HttpServletRequest request, @RequestParam(name = "title", required = true) String title) {
        return super.exportXls(title, new ArrayList<>(), AssetLedgerVo.class, false);
    }

    /**
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/dict/importExcel", method = RequestMethod.POST)
    public Result<?> importDictExcel(HttpServletRequest request, HttpServletResponse response) {

        try {
            List<Map<String, String>> list = super.importExcelBase(request, response, Map.class, 0, 1);

            List<String> errorMessage = new ArrayList<>();
            int successLines = 0, errorLines = 0;

            // 错误信息
            int size = list.size();
            for (int i = 0; i < size; i++) {
                try {
                    Map<String, String> map = list.get(i);
                    SysDictItem sysDictItem = new SysDictItem();
                    for (Map.Entry<String, String> a : map.entrySet()) {
                        if (StringUtils.isBlank(a.getValue()) || StringUtils.isBlank(a.getKey())) {
                            continue;
                        }
                        sysDictItem.setDictId(oConvertUtils.replaceBlank(a.getKey()));
                        sysDictItem.setItemText(oConvertUtils.replaceBlank(a.getValue()));
                    }
                    sysDictItem.setItemValue(String.valueOf(i + 1));
                    sysDictItem.setStatus(1);
                    boolean bool = sysDictItemService.save(sysDictItem);
                    if (bool) {
                        successLines++;
                    } else {
                        errorLines++;
                        int lineNumber = i + 1;
                        errorMessage.add("第 " + lineNumber + " 行：导入失败，数据已存在。");
                    }
                } catch (JeecgBootException e) {
                    errorLines++;
                    int lineNumber = i + 1;
                    errorMessage.add("第 " + lineNumber + " 行：" + e.getMessage() + "。");
                } catch (Exception e) {
                    errorLines++;
                    int lineNumber = i + 1;
                    log.error(e.getMessage(), e);
                    errorMessage.add("第 " + lineNumber + " 行：导入失败。");
                }
            }
            return ImportExcelUtil.imporReturnRes(errorLines, successLines, errorMessage);
        } catch (Exception e) {
//            e.printStackTrace();
            log.error(e.getMessage(), e);
        }
        return Result.ok("文件导入失败！");
    }

//    /**
//     * 通过excel导入数据
//     *
//     * @param request
//     * @param response
//     * @return
//     */
//    @AutoLog(value = "资产台账-excel导入数据")
//    @RequestMapping(value = "/assetLedger/importExcel", method = RequestMethod.POST)
//    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
//        try {
//            List<AssetLedgerVo> list = super.importExcelBase(request, response, AssetLedgerVo.class);
////                // 错误信息
//            List<String> errorMessage = new ArrayList<>();
//            AtomicInteger successLines = new AtomicInteger();
//            AtomicInteger errorLines = new AtomicInteger();
//            list.stream().forEach(vo->{
//                try {
//                    if (StringUtils.isBlank(vo.getAssetName())) {
//                        vo.setAssetName(vo.getSite());
//                    }
//                    if ("有".equalsIgnoreCase(vo.getIsPropertyStr())) {
//                        vo.setIsProperty(1);
//                    }
//                    vo.setPaymentDeadline(DateFormatUtil.getDate(vo.getPaymentDeadlineStr()));
//                    vo.setPullTime(DateFormatUtil.getDate(vo.getPullTimeStr()));
//                    vo.setReceiptTime(DateFormatUtil.getDate(vo.getReceiptTimeStr()));
//                    vo.setRentStartTime(DateFormatUtil.getDate(vo.getRentStartTimeStr()));
//                    vo.setRentEndTime(DateFormatUtil.getDate(vo.getRentEndTimeStr()));
//                    vo.setRentHolidayStart(DateFormatUtil.getDate(vo.getRentHolidayStartStr()));
//                    vo.setRentHolidayEnd(DateFormatUtil.getDate(vo.getRentHolidayEndStr()));
//
//                    boolean bool = assetInfoService.saveByAssetLedger(vo);
//                    if (bool) {
//                        successLines.getAndIncrement();
//                    } else {
//                        errorLines.getAndIncrement();
//                        errorMessage.add("第" + vo.getRowNumber() + "行数据：导入失败，数据已存在。");
//                        log.info("第" + vo.getRowNumber() + "行数据：导入失败，数据已存在。");
//                    }
//                } catch (JeecgBootException e) {
//                    errorLines.getAndIncrement();
//                    log.info("第" + vo.getRowNumber() + "行数据：" + e.getMessage() + "。");
//                    errorMessage.add("第" + vo.getRowNumber() + "行数据：" + e.getMessage() + "。");
//                    log.error(e.getMessage(), e);
//                } catch (Exception e) {
//                    errorLines.getAndIncrement();
//                    log.info("第" + vo.getRowNumber() + "行数据：导入失败。");
//                    log.error(e.getMessage(), e);
//                    errorMessage.add("第" + vo.getRowNumber() + "行数据：导入失败。");
//
//                }
//            });
//            return ImportExcelUtil.imporReturnRes(errorLines.get(), successLines.get(), errorMessage);
//        } catch (Exception e) {
//            log.error(e.getMessage(), e);
//        }
//        return Result.ok("文件导入失败！");
//    }



    /**
     * 应收已收未收列表查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "应收已收未收-分页列表查询")
    @ApiOperation(value = "应收已收未收-分页列表查询", notes = "应收已收未收-分页列表查询")
    @GetMapping(value = "/collectionInformation")
    public Result<IPage<CollectionInformationVo>> queryCollectionInformationPageList(CollectionInformationVo vo,
                                                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                                     HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<CollectionInformationVo> queryWrapper = new QueryWrapper<>(vo);
        Page<CollectionInformationVo> page = new Page<>(pageNo, pageSize);
        IPage<CollectionInformationVo> pageList = receivablesInfoService.queryCollectionInformationVoList(page, queryWrapper);
        return Result.ok(pageList);
    }


    /**
     * 应收已收未收导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "应收已收未收-导出excel")
    @ApiOperation(value = "应收已收未收-导出excel", notes = "应收已收未收-导出excel")
    @RequestMapping(value = "/collectionInformation/exportXls")
    public ModelAndView exportCollectionInformationXls(HttpServletRequest req, CollectionInformationVo vo) {
        List<CollectionInformationVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<CollectionInformationVo> queryWrapper = new QueryWrapper<>();
            CollectionInformationVo vo1 = new CollectionInformationVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList = receivablesInfoService.queryCollectionInformationVoList(queryWrapper);
        } else {
            QueryWrapper<CollectionInformationVo> queryWrapper = new QueryWrapper<>(vo);
            pageList = receivablesInfoService.queryCollectionInformationVoList(queryWrapper);
        }

        return super.exportXls("应收已收未收信息", pageList, CollectionInformationVo.class, true);
    }

    /**
     * 资产台账下载excel模版
     *
     * @param request
     * @param title
     */
    @ApiOperation(value = "应收已收未收-分页列表查询", notes = "应收已收未收-分页列表查询")
    @RequestMapping(value = "/collectionInformation/exportXlsTemplate")
    public ModelAndView exportCollectionInformationXlsTemplate(HttpServletRequest request, @RequestParam(name = "title", required = true) String title) {
        return super.exportXls(title, new ArrayList<>(), CollectionInformationVo.class, false);
    }


    /**
     * 资产台账列表查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "资产台账列表查询-分页列表查询")
    @ApiOperation(value = "资产台账列表查询-分页列表查询", notes = "资产台账列表查询-分页列表查询")
    @GetMapping(value = "/assetsParameter")
    public Result<IPage<AssetsParameterVo>> queryAssetsParameterPageList(AssetsParameterVo vo,
                                                                             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                             HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<AssetsParameterVo> queryWrapper = new QueryWrapper<>(vo);
        Page<AssetsParameterVo> page = new Page<>(pageNo, pageSize);
        IPage<AssetsParameterVo> pageList = assetInfoService.queryAssetsParameterVoList(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 资产台账导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "资产台账-导出excel")
    @RequestMapping(value = "/assetsParameter/exportXls")
    public ModelAndView AssetsParameterExportXls(HttpServletRequest req, AssetsParameterVo vo) {
        List<AssetsParameterVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<AssetsParameterVo> queryWrapper = new QueryWrapper<>();
            AssetsParameterVo vo1 = new AssetsParameterVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList = assetInfoService.queryAssetsParameterVoList(queryWrapper);
        } else {
            QueryWrapper<AssetsParameterVo> queryWrapper = new QueryWrapper<>(vo);
            pageList = assetInfoService.queryAssetsParameterVoList(queryWrapper);
        }

        return super.exportXls("资产台账信息", pageList, AssetsParameterVo.class, true);
    }

    /**
     * 合同台账列表查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "合同台账列表查询-分页列表查询")
    @ApiOperation(value = "合同台账列表查询-分页列表查询", notes = "合同台账列表查询-分页列表查询")
    @GetMapping(value = "/contractParameter")
    public Result<IPage<ContractParameterVo>> queryContractParameterPageList(ContractParameterVo vo,
                                                                             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                             HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<ContractParameterVo> queryWrapper = new QueryWrapper<>(vo);
        Page<ContractParameterVo> page = new Page<>(pageNo, pageSize);
        IPage<ContractParameterVo> pageList = contractInfoService.queryContractParameterVoList(page, queryWrapper);
        return Result.ok(pageList);
    }

    @AutoLog(value = "合同台账-查询合计")
    @ApiOperation(value = "合同台账-查询合计", notes = "合同台账-查询合计")
    @GetMapping(value = "/getContractParameterSum")
    public Result getContractParameterSum(ContractParameterVo vo){
        QueryWrapper<ContractParameterVo> queryWrapper = new QueryWrapper<>(vo);
        ContractParameterSumVo  sumVo = contractInfoService.getContractParameterSum(queryWrapper);
        return Result.ok(sumVo);
    }


    /**
     * 合同台账导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "合同台账-导出excel")
    @RequestMapping(value = "/contractParameter/exportXls")
    public ModelAndView ContractParameterExportXls(HttpServletRequest req, ContractParameterVo vo) {
        List<ContractParameterVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<ContractParameterVo> queryWrapper = new QueryWrapper<>();
            ContractParameterVo vo1 = new ContractParameterVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList = contractInfoService.queryContractParameterVoList(queryWrapper);
        } else {
            QueryWrapper<ContractParameterVo> queryWrapper = new QueryWrapper<>(vo);
            pageList = contractInfoService.queryContractParameterVoList(queryWrapper);
        }

        return super.exportXls("合同台账信息", pageList, ContractParameterVo.class, true);
    }

    /**
     * 客户缴费统计查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "客户缴费统计查询-分页列表查询")
    @ApiOperation(value = "客户缴费统计查询-分页列表查询", notes = "客户缴费统计查询-分页列表查询")
    @GetMapping(value = "/customerPayment")
    public Result<IPage<CustomerPaymentVo>> queryCustomerPaymentPageList(CustomerPaymentVo vo,
                                                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                         HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<CustomerPaymentVo> queryWrapper = new QueryWrapper<>(vo);
        Page<CustomerPaymentVo> page = new Page<>(pageNo, pageSize);
        IPage<CustomerPaymentVo> pageList = customerInfoService.queryCustomerPaymentVoList(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 客户缴费统计导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "客户缴费统计-导出excel")
    @RequestMapping(value = "/customerPayment/exportXls")
    public ModelAndView CustomerPaymentExportXls(HttpServletRequest req, CustomerPaymentVo vo) {
        List<CustomerPaymentVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<CustomerPaymentVo> queryWrapper = new QueryWrapper<>();
            CustomerPaymentVo vo1 = new CustomerPaymentVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList = customerInfoService.queryCustomerPaymentVoList(queryWrapper);
        } else {
            QueryWrapper<CustomerPaymentVo> queryWrapper = new QueryWrapper<>(vo);
            pageList = customerInfoService.queryCustomerPaymentVoList(queryWrapper);
        }

        return super.exportXls("客户缴费统计", pageList, CustomerPaymentVo.class, true);
    }

    /**
     * 保证金统计查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "保证金统计查询-分页列表查询")
    @ApiOperation(value = "保证金统计查询-分页列表查询", notes = "保证金统计查询-分页列表查询")
    @GetMapping(value = "/depositStatistical")
    public Result<IPage<DepositStatisticalVo>> queryDepositStatisticalPageList(DepositStatisticalVo vo,
                                                                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                               HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<DepositStatisticalVo> queryWrapper = new QueryWrapper<>(vo);
        Page<DepositStatisticalVo> page = new Page<>(pageNo, pageSize);
        IPage<DepositStatisticalVo> pageList = contractInfoService.queryDepositStatisticalVoList(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 保证金统计导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "保证金统计-导出excel")
    @RequestMapping(value = "/depositStatistical/exportXls")
    public ModelAndView DepositStatisticalExportXls(HttpServletRequest req, DepositStatisticalVo vo) {
        List<DepositStatisticalVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<DepositStatisticalVo> queryWrapper = new QueryWrapper<>();
            DepositStatisticalVo vo1 = new DepositStatisticalVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList = contractInfoService.queryDepositStatisticalVoList(queryWrapper);
        } else {
            QueryWrapper<DepositStatisticalVo> queryWrapper = new QueryWrapper<>(vo);
            pageList = contractInfoService.queryDepositStatisticalVoList(queryWrapper);
        }

        return super.exportXls("客户缴费统计", pageList, DepositStatisticalVo.class, true);
    }

    /**
     * 缴费记录统计查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "缴费记录统计查询-分页列表查询")
    @ApiOperation(value = "缴费记录统计查询-分页列表查询", notes = "缴费记录统计查询-分页列表查询")
    @GetMapping(value = "/paymentRecords")
    public Result<IPage<PaymentRecordsVo>> queryPaymentRecordsPageList(PaymentRecordsVo vo,
                                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                       HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<PaymentRecordsVo> queryWrapper = new QueryWrapper<>(vo);
        Page<PaymentRecordsVo> page = new Page<>(pageNo, pageSize);
        IPage<PaymentRecordsVo> pageList = receivablesInfoService.queryPaymentRecordsList(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 缴费记录统计导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "缴费记录统计-导出excel")
    @RequestMapping(value = "/paymentRecords/exportXls")
    public ModelAndView DepositStatisticalExportXls(HttpServletRequest req, PaymentRecordsVo vo) {
        List<PaymentRecordsVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<PaymentRecordsVo> queryWrapper = new QueryWrapper<>();
            PaymentRecordsVo vo1 = new PaymentRecordsVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList =  receivablesInfoService.queryPaymentRecordsList(queryWrapper);
        } else {
            QueryWrapper<PaymentRecordsVo> queryWrapper = new QueryWrapper<>(vo);
            pageList =  receivablesInfoService.queryPaymentRecordsList(queryWrapper);
        }

        return super.exportXls("缴费记录统计", pageList, PaymentRecordsVo.class, true);
    }

    /**
     * 预存记录统计查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "预存记录统计查询-分页列表查询")
    @ApiOperation(value = "预存记录统计查询-分页列表查询", notes = "预存记录统计查询-分页列表查询")
    @GetMapping(value = "/persistingRecords")
    public Result<IPage<PersistingRecordsVo>> queryPersistingRecordsPageList(PersistingRecordsVo vo,
                                                                             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                             HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<PersistingRecordsVo> queryWrapper = new QueryWrapper<>(vo);
        Page<PersistingRecordsVo> page = new Page<>(pageNo, pageSize);
        IPage<PersistingRecordsVo> pageList = orderPrestoreService.queryPersistingRecordsPageList(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 预存记录统计导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "预存记录统计-导出excel")
    @RequestMapping(value = "/persistingRecords/exportXls")
    public ModelAndView DepositStatisticalExportXls(HttpServletRequest req, PersistingRecordsVo vo) {
        List<PersistingRecordsVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<PersistingRecordsVo> queryWrapper = new QueryWrapper<>();
            PersistingRecordsVo vo1 = new PersistingRecordsVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList =  orderPrestoreService.queryPersistingRecordsPageList(queryWrapper);
        } else {
            QueryWrapper<PersistingRecordsVo> queryWrapper = new QueryWrapper<>(vo);
            pageList =  orderPrestoreService.queryPersistingRecordsPageList(queryWrapper);
        }

        return super.exportXls("预存记录统计", pageList, PersistingRecordsVo.class, true);
    }


    /**
     * 账单已收未收统计查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "账单已收未收统计查询-分页列表查询")
    @ApiOperation(value = "账单已收未收统计查询-分页列表查询", notes = "账单已收未收统计查询-分页列表查询")
    @GetMapping(value = "/billReceivablesDetails")
    public Result<IPage<BillReceivablesDetailsVo>> queryBillReceivablesDetailsPageList(BillReceivablesDetailsVo vo,
                                                                             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                             HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<BillReceivablesDetailsVo> queryWrapper = new QueryWrapper<>(vo);
        Page<BillReceivablesDetailsVo> page = new Page<>(pageNo, pageSize);
        IPage<BillReceivablesDetailsVo> pageList = receivablesInfoService.queryBillReceivablesDetailsPageList(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 账单已收未收统计统计导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "账单已收未收统计-导出excel")
    @RequestMapping(value = "/billReceivablesDetails/exportXls")
    public ModelAndView BillReceivablesDetailsVoExportXls(HttpServletRequest req, BillReceivablesDetailsVo vo) {
        List<BillReceivablesDetailsVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<BillReceivablesDetailsVo> queryWrapper = new QueryWrapper<>();
            BillReceivablesDetailsVo vo1 = new BillReceivablesDetailsVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList = receivablesInfoService.queryBillReceivablesDetailsList(queryWrapper);
        } else {
            QueryWrapper<BillReceivablesDetailsVo> queryWrapper = new QueryWrapper<>(vo);
            pageList =  receivablesInfoService.queryBillReceivablesDetailsList(queryWrapper);
        }

        return super.exportXls("账单已收未收统计", pageList, BillReceivablesDetailsVo.class, true);
    }


    /**
     * 维修统计查询
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "维修统计查询-分页列表查询")
    @ApiOperation(value = "维修统计查询-分页列表查询", notes = "维修统计查询-分页列表查询")
    @GetMapping(value = "/maintenanceStatistical")
    public Result<IPage<MaintenanceStatisticalVo>> queryMaintenanceStatisticalPageList(MaintenanceStatisticalVo vo,
                                                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                                       HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<MaintenanceStatisticalVo> queryWrapper = new QueryWrapper<>(vo);
        Page<MaintenanceStatisticalVo> page = new Page<>(pageNo, pageSize);
        IPage<MaintenanceStatisticalVo> pageList = repairInfoService.queryMaintenanceStatisticalPageList(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 维修统计导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "维修统计-导出excel")
    @RequestMapping(value = "/MaintenanceStatistical/exportXls")
    public ModelAndView MaintenanceStatisticalExportXls(HttpServletRequest req, MaintenanceStatisticalVo vo) {
        List<MaintenanceStatisticalVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<MaintenanceStatisticalVo> queryWrapper = new QueryWrapper<>();
            MaintenanceStatisticalVo vo1 = new MaintenanceStatisticalVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList = repairInfoService.queryMaintenanceStatisticalList(queryWrapper);
        } else {
            QueryWrapper<MaintenanceStatisticalVo> queryWrapper = new QueryWrapper<>(vo);
            pageList =  repairInfoService.queryMaintenanceStatisticalList(queryWrapper);
        }

        return super.exportXls("维修统计", pageList, MaintenanceStatisticalVo.class, true);
    }


    /**
     * 对公账户收支明细
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "对公账户收支明细-分页列表查询")
    @ApiOperation(value = "对公账户收支明细-分页列表查询", notes = "对公账户收支明细-分页列表查询")
    @GetMapping(value = "/broughtAccount")
    public Result<IPage<BroughtAccountVo>> queryBroughtAccountPageList(BroughtAccountVo vo,
                                                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                                       HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<BroughtAccountVo> queryWrapper = new QueryWrapper<>(vo);
        Page<BroughtAccountVo> page = new Page<>(pageNo, pageSize);
        IPage<BroughtAccountVo> pageList = publicAccountTransactionInquiryDetailsService.queryBroughtAccountPageList(page, queryWrapper);
        return Result.ok(pageList);
    }

    /**
     * 对公账户收支明细统计导出excel
     *
     * @param req
     * @param vo
     */
    @AutoLog(value = "对公账户收支明细-导出excel")
    @RequestMapping(value = "/broughtAccount/exportXls")
    public ModelAndView BroughtAccountExportXls(HttpServletRequest req, BroughtAccountVo vo) {
        List<BroughtAccountVo> pageList;
        String selections = req.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            QueryWrapper<BroughtAccountVo> queryWrapper = new QueryWrapper<>();
            BroughtAccountVo vo1 = new BroughtAccountVo();
            vo1.setSelections(selections);
            queryWrapper.setEntity(vo1);
            pageList =publicAccountTransactionInquiryDetailsService.queryBroughtAccountList(queryWrapper);
        } else {
            QueryWrapper<BroughtAccountVo> queryWrapper = new QueryWrapper<>(vo);
            pageList =  publicAccountTransactionInquiryDetailsService.queryBroughtAccountList(queryWrapper);
        }

        return super.exportXls("对公账户收支明细", pageList, MaintenanceStatisticalVo.class, true);
    }



    /**
     * 个人在线平台支付对账表
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "个人在线平台支付对账表-分页列表查询")
    @ApiOperation(value = "个人在线平台支付对账表-分页列表查询", notes = "个人在线平台支付对账表-分页列表查询")
    @GetMapping(value = "/personalOnlinePlatformPayment")
    public Result<IPage<PersonalOnlinePlatformPaymentVo>> queryPersonalOnlinePlatformPaymentPageList(PersonalOnlinePlatformPaymentVo vo,
                                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                       HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<PersonalOnlinePlatformPaymentVo> queryWrapper = new QueryWrapper<>(vo);
        Page<PersonalOnlinePlatformPaymentVo> page = new Page<>(pageNo, pageSize);
        IPage<PersonalOnlinePlatformPaymentVo> pageList = payablesInfoService.queryPersonalOnlinePlatformPaymentPageList(page, queryWrapper);
        return Result.ok(pageList);
    }


    /**
     * 资产台账汇总
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "资产台账汇总-分页列表查询")
    @ApiOperation(value = "资产台账汇总-分页列表查询", notes = "资产台账汇总-分页列表查询")
    @GetMapping(value = "/assetsParameterStatistical")
    public Result<IPage<AssetsParameterStatisticalVo>> queryAssetsParameterStatisticalPageList(AssetsParameterStatisticalVo vo,
                                                                                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                                               HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<AssetsParameterStatisticalVo> queryWrapper = new QueryWrapper<>(vo);
        Page<AssetsParameterStatisticalVo> page = new Page<>(pageNo, pageSize);
        IPage<AssetsParameterStatisticalVo> pageList = assetInfoService.queryAssetsParameterStatisticalPageList(page, queryWrapper);
        return Result.ok(pageList);
    }


    /**
     * 经营收入汇总
     *
     * @param vo
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @AutoLog(value = "经营收入汇总-分页列表查询")
    @ApiOperation(value = "经营收入汇总-分页列表查询", notes = "经营收入汇总-分页列表查询")
    @GetMapping(value = "/incomeOperatingStatistical")
    public Result<IPage<IncomeOperatingStatisticalVo>> queryIncomeOperatingStatisticalPageList(IncomeOperatingStatisticalVo vo,
                                                                                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                                               HttpServletRequest req) {
        vo.setSelections(null);
        QueryWrapper<IncomeOperatingStatisticalVo> queryWrapper = new QueryWrapper<>(vo);
        Page<IncomeOperatingStatisticalVo> page = new Page<>(pageNo, pageSize);
        IPage<IncomeOperatingStatisticalVo> pageList = receivablesInfoService.queryIncomeOperatingStatisticalPageList(page, queryWrapper);
        return Result.ok(pageList);
    }

}
